package examples.springcloud.controller;

import examples.springcloud.dto.UserDTO;
import org.apache.shenyu.client.apidocs.annotations.ApiDoc;
import org.apache.shenyu.client.apidocs.annotations.ApiModule;
import org.apache.shenyu.client.springcloud.annotation.ShenyuGetMapping;
import org.apache.shenyu.client.springcloud.annotation.ShenyuPostMapping;
import org.apache.shenyu.client.springcloud.annotation.ShenyuRequestMapping;
import org.springframework.web.bind.annotation.*;

/**
 * TestController.
 */
@RestController
@ShenyuRequestMapping("/test2")
@ApiModule("/test2")
public class Test2Controller {


    /**
     * Post string.
     *
     * @param userDTO the user dto
     * @return the string
     */
    @ShenyuPostMapping("/save")
    @ApiDoc(desc = "/save")
    public UserDTO post(@RequestBody final UserDTO userDTO) {
        userDTO.setUserName("hello world spring cloud save user");
        return userDTO;
    }

    /**
     * Find by user id user dto.
     *
     * @param userId the user id
     * @return the user dto
     */
    @ShenyuGetMapping("/findByUserId")
    @ApiDoc(desc = "/findByUserId")
    public UserDTO findByUserId(@RequestParam("userId") final String userId) {
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(userId);
        userDTO.setUserName("hello world spring cloud findBy user");
        return userDTO;
    }
}
